package com.example.administrator.myapplication.muscle;

import android.graphics.Color;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.NumberPicker;
import android.widget.Toast;

import com.example.administrator.myapplication.R;


public class muscle_main_Fragment extends Fragment   {
    private NumberPicker muscle_numberpicker;
    private Button muscle_submit_bt;
    private ImageView muscle_boy_pic;
    private ImageView muscle_girl_pic;
    private Boolean flag_boy=false;
    private Boolean flag_girl=false;
    private Integer value ;


    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        View view = inflater.inflate(R.layout.fragment_muscle_main_, container, false);
        init(view);
        muscle_numberpicker.setMinValue(0);
        muscle_numberpicker.setMaxValue(200);
        muscle_numberpicker.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,250));
        muscle_numberpicker.setOnValueChangedListener(new NumberPicker.OnValueChangeListener() {
            @Override
            public void onValueChange(NumberPicker picker, int oldVal, int newVal) {
                    value=newVal;
            }
        });
        muscle_girl_pic.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if(!flag_boy&&!flag_girl){
                    flag_girl=true;
                    muscle_girl_pic.setImageResource(R.drawable.muscle_option_girl_selected);
                }
                if(flag_boy&&!flag_girl){
                    flag_girl=true;
                    flag_boy=false;
                    muscle_boy_pic.setImageResource(R.drawable.muscle_option_boy_default);
                    muscle_girl_pic.setImageResource(R.drawable.muscle_option_girl_selected);
                }
            }
        });

        muscle_boy_pic.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if(!flag_boy&&!flag_girl){
                    flag_boy=true;
                    muscle_boy_pic.setImageResource(R.drawable.muscle_option_boy_selected);
                }
                if(!flag_boy&&flag_girl){
                    flag_boy=true;
                    flag_girl=false;
                    muscle_girl_pic.setImageResource(R.drawable.muscle_option_girl_default);
                    muscle_boy_pic.setImageResource(R.drawable.muscle_option_boy_selected);
                }
            }
        });


        muscle_submit_bt.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                if(flag_boy){
                  Toast.makeText(getActivity(),"性别男"+String.valueOf(value),Toast.LENGTH_SHORT).show();
                }
                if(flag_girl){
                    Toast.makeText(getActivity(),"性别女"+String.valueOf(value),Toast.LENGTH_SHORT).show();
                }
            }

























































































































































































































































































































































































































        });'
        '
        return view;
    }

    public void init(View v){
        muscle_numberpicker=(NumberPicker)v.findViewById(R.id.muscle_numberpicker);
        muscle_boy_pic=(ImageView)v.findViewById(R.id.muscle_selected_boy);
        muscle_girl_pic=(ImageView)v.findViewById(R.id.muscle_selected_girl);
        muscle_submit_bt=(Button)v.findViewById(R.id.muscle_submit_bt);
    }
}
